<%--
  Created by IntelliJ IDEA.
  User: gaoliwei02
  Date: 17/6/25
  Time: 上午10:31
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>system information</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/button_demo1.css">
</head>

<body>
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        system information
        <small>page</small>
    </h1>
</section>

<section class="content">
    <div class="box">
        <%--<div class="box-header with-border"></div><!-- /.box-header -->--%>
        <div class="box-body">
            <div class="row">
                <div class="col-lg-12  col-xs-12" id="m_table">
                    <table class="table">
                        <caption>系统参数</caption>
                        <thead>
                        <tr>
                            <th>process</th>
                            <th>USER</th>
                            <th>PID</th>
                            <th>CPU</th>
                            <th>MEM</th>
                            <th>VSZ</th>
                            <th>RSS</th>
                        </tr>
                        </thead>
                        <tbody id="m_tbody">
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>

<script>
    $(document).ready(function () {
        queryParams();
        setInterval("queryParams()", 10000);
        //setTimeout("queryParams()", 1000)
    });

    function queryParams() {
        $("#m_tbody").text("");
        var send_data = {
            "system": "get"
        };
        send_json_data = (JSON.stringify(send_data));

        $.ajax({
            type: 'POST',
            url: "/system/getshell.inner",
            contentType: 'application/json',
            dataType: "json",
            data: send_json_data,
            timeout: 30000,
            success: function (data) {
                var dataObj = eval(data);
                parse(dataObj);
                //$("#m_table").append(data.ls);
                //alert(JSON.stringify(data));
                //alert(index + " " + JSON.stringify(content));
            }
        });
    }

    function parse(dataObj) {
        var array1 = dataObj.server;
        $.each(array1, function (index, content) {
            var str = "<tr><td>" + "server" + "</td><td>" + content.USER + "</td><td>" + content.PID + "</td><td>" + content.CPU + "%" + "</td><td>" + content.MEM + "%" + "</td><td>" + content.VSZ/1000.0 + "M" + "</td><td>" + content.RSS/1000.0 + "M" + "</td></tr>"
            $("#m_tbody").append(str);
        });

        var array2 = dataObj.front;
        $.each(array2, function (index, content) {
            var str = "<tr><td>" + "front" + "</td><td>" + content.USER + "</td><td>" + content.PID + "</td><td>" + content.CPU + "%" + "</td><td>" + content.MEM + "%" + "</td><td>" + content.VSZ/1000.0 + "M" + "</td><td>" + content.RSS/1000.0 + "M" + "</td></tr>"
            $("#m_tbody").append(str);
        });

        var array3 = dataObj.mysql;
        $.each(array3, function (index, content) {
            var str = "<tr><td>" + "mysql" + "</td><td>" + content.USER + "</td><td>" + content.PID + "</td><td>" + content.CPU + "%" + "</td><td>" + content.MEM + "%" + "</td><td>" + content.VSZ/1000.0 + "M" + "</td><td>" + content.RSS/1000.0 + "M" + "</td></tr>"
            $("#m_tbody").append(str);
        });

        var array4 = dataObj.logstash;
        $.each(array4, function (index, content) {
            var str = "<tr><td>" + "logstash" + "</td><td>" + content.USER + "</td><td>" + content.PID + "</td><td>" + content.CPU + "%" + "</td><td>" + content.MEM + "%" + "</td><td>" + content.VSZ/1000.0 + "M" + "</td><td>" + content.RSS/1000.0 + "M" + "</td></tr>"
            $("#m_tbody").append(str);
        });

        var array5 = dataObj.elasticsearch;
        $.each(array5, function (index, content) {
            var str = "<tr><td>" + "elasticsearch" + "</td><td>" + content.USER + "</td><td>" + content.PID + "</td><td>" + content.CPU + "%" + "</td><td>" + content.MEM + "%" + "</td><td>" + content.VSZ/1000.0 + "M" + "</td><td>" + content.RSS/1000.0 + "M" + "</td></tr>"
            $("#m_tbody").append(str);
        });
    }
</script>

</body>
</html>
